package com.mc2.docapp.disabilityassessmenttool.UpperLimb;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Class_arm_component {
    private C_active_rom active_rom_degrees = new C_active_rom();
    //ACTIVE ROM (degrees)
    private C_UL_muscle_power muscle_power = new C_UL_muscle_power();
    //MUSCLE POWER (x/5) (x=0 to5)
    private C_loss_in_10_co_ordinated_activities loss_in_10_co_ordinated_activities = new C_loss_in_10_co_ordinated_activities();
    //LOSS IN 10 CO-ORDINATED ACTIVITIES (max. 9% each)

    private double totalArmCommponentLeft = 0;
    private double totalArmCommponentRight = 0;

    private void calTotalArmComp (Class_arm_component dt, Boolean isLeft) {
        //LEFT CALCULATIONb

        if(isLeft) {
            double activeRom = dt.getActive_rom_degrees().getInnerCalculations().getSummation_left();
            double muscePoer = dt.getMuscle_power().getInnerCalculations().getSummation_left();
            double coActivities = dt.getLoss_in_10_co_ordinated_activities().getInner_calculations().getSummation_left();

            double step1;
            double step2;

            step1 = calByFormula(activeRom,muscePoer);
            step2 = calByFormula(step1,coActivities);
            if(step2 > 90d) {
                dt.setTotalArmCommponentLeft(90d);
            } else {
                dt.setTotalArmCommponentLeft(step2);
            }

        } else {
            //RIGHT CALCULATION
            double activeRom = dt.getActive_rom_degrees().getInnerCalculations().getSummation_right();
            double muscePoer = dt.getMuscle_power().getInnerCalculations().getSummation_right();
            double coActivities = dt.getLoss_in_10_co_ordinated_activities().getInner_calculations().getSummation_right();

            double step1;
            double step2;

            step1 = calByFormula(activeRom,muscePoer);
            step2 = calByFormula(step1,coActivities);
            if(step2 > 90d) {
                dt.setTotalArmCommponentRight(90d);
            } else {
                dt.setTotalArmCommponentRight(step2);
            }


        }

    }

    private double calByFormula(double a, double b) {
        if(a<b){
            a = a + b;
            b = a - b;
            a = a - b;
        }
        double c = a + (((90 - a) * b) / 90.0);
        return c;
    }
}